package com.qqzone.qq.dao.impl;

import com.qqzone.myssm.basedao.BaseDAO;
import com.qqzone.qq.dao.ReplyDao;
import com.qqzone.qq.pojo.Reply;
import com.qqzone.qq.pojo.Topic;

import java.util.List;

public class ReplyDaoImpl extends BaseDAO<Reply> implements ReplyDao {
    @Override
    public List<Reply> getReplyList(Topic topic) {
        return super.executeQuery("select * from t_reply where topic = ?", topic.getId());
    }

    @Override
    public int addReply(Reply reply) {
        return super.executeUpdate("insert into t_reply values(null, ?, ?, ?, ?)", reply.getContent(), reply.getReplyDate(), reply.getAuthor().getId(), reply.getTopic().getId());
    }

    @Override
    public int delReply(Integer id) {
        return super.executeUpdate("delete from t_reply where id = ?", id);
    }

    @Override
    public Reply getReply(Integer id) {
        return super.load("select * from t_reply where id = ?", id);
    }
}
